#include<bits/stdc++.h>
using namespace std;
const int M=1e5;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    long long T,n,m,L,V,v,a,ans;
    long long p[M];
    float c,d;
    cin>>T;
    for(int i=1;i<=T;i++){
        cin>>n>>m>>L>>V;//V for speed's maximum
        for(int i=1;i<=n;i++){
            cin>>d>>v>>a;//v for current car's speed
            /*if(a!=0){
                b=1;
            }*/
            if(v>=V ){
                ans++;
            }
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
    }
    for(int i=1;i<=T;i++){
        for(int i=1;i<=m;i++){
            c=(V*V-v*v)/(2*a)*1.0;
            d= ((V-v)/a)*V;
            if(c>d && d<=p[i]){
                ans++;
            }
        }
        cout<<ans<<" "<<m-1<<endl;
        ans=0;
    }


    fclose(stdin);
    fclose(stdout);
    return 0;
}
/*
    int b=0;
    for(int i=1;i<=n;i++){
        cin>>d>>v>>a;
        if(a!=0){
            b=1;
        }
        if(u==v){
            ans++;
        }
    if(b==0){
        cout<<ans<<" "<<m-1<<endl;
    else{
        cout<<m<<" "<<m<<endl;

*/
